angular.module('myApp',[])
  .controller('MyCtrl',function ($scope) {
    // 初始化message
    $scope.message = '';

    $scope.getCount = function () {
      // 获取0~100个字符
      if($scope.message.length > 100){
        $scope.message = $scope.message.slice(0,100);
      }
      return 100- $scope.message.length;
    }

    // 定义保存数据
    $scope.save = function () {
      alert('note is saved');
      sessionStorage.setItem('note_key',JSON.stringify($scope.message));
      $scope.message = '';
    }

    // 定义读取数据
    $scope.read = function () {
      $scope.message = JSON.parse(sessionStorage.getItem('note_key')||'[]');
    }

    // 定义删除数据
    $scope.remove = function () {
      alert('note is removed');
      $scope.message = sessionStorage.removeItem('note_key');
      $scope.message = '';
    }
  })